package com.example.ruralservicedigitalplatform.mapper;

import com.example.ruralservicedigitalplatform.domain.po.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface AdminMapper {
    //根据用户名及密码查询管理员
    @Select("select *from villager_platform.admin where admin_name = #{adminName} and password = #{password}")
    Admin getByUsernameAndPassword(Admin admin);

    //管理员信息的分页查询
    public List<Admin> list(String adminName, Integer gender,String phoneNumber, Integer age,
                            String image,String idNumber,LocalDate begin, LocalDate end);

    //更改管理员信息
    void update(Admin admin);

    //新增管理员
    @Insert("insert into villager_platform.admin(admin_name,password,gender,phone_number,age,image,id_number,create_time,update_time) VALUES " +
            "(#{adminName},#{password},#{gender},#{phoneNumber},#{age},#{image},#{idNumber},#{createTime},#{updateTime})")
    void insert(Admin admin);

    //删除管理员
    void delete(List<Integer> ids);
}
